//
//  YJRightSmallFunctionView.m
//  YJZhuYunApp
//
//  Created by 张龙 on 16/10/26.
//  Copyright © 2016年 张龙. All rights reserved.
//

#import "YJRightSmallFunctionView.h"

@interface YJRightSmallFunctionView()<UITableViewDelegate,UITableViewDataSource>

@property(nonatomic,strong)NSArray *dataArray;

@end

@implementation YJRightSmallFunctionView

- (instancetype)initWithFrame:(CGRect)frame{
   self = [super initWithFrame:frame];
    if (self) {
        // Initialization code

        self.backgroundColor = [UIColor clearColor];
        self.dataArray = [NSMutableArray arrayWithObjects:@"发送给朋友", @"分享到校园圈", @"分享到手机QQ", @"复制链接", @"刷新", nil];    //数据源
        
        UITableView  *tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0,150,220) style:UITableViewStylePlain];
        tableView.delegate = self;
        tableView.dataSource = self;
        tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        [self addSubview:tableView];
    }
    return self;
}

#pragma mark - TableView Delegate
- (NSInteger )numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 5;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *identifier = @"cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.backgroundColor = [UIColor colorWithRed:0.0/255.0f green:0.0/255.0f blue:0.0/255.0f alpha:0.7];

        UIImageView *imageView = [[UIImageView alloc]init];
        imageView.frame = CGRectMake( 15, 12, 20, 20);
        imageView.contentMode = UIViewContentModeScaleToFill;
        imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"share_icon0%ld",((long)indexPath.row + 1)]];
        [cell.contentView addSubview:imageView];

        UILabel *label = [[UILabel alloc]init];
        label.frame = CGRectMake( 45, 7, 200, 30);
        label.textColor = [UIColor whiteColor];
        label.font = [UIFont systemFontOfSize:15];
        label.text = self.dataArray[indexPath.row];
        [cell.contentView addSubview:label];
    }

    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 44;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (self.didSelectBlock) {
        self.didSelectBlock(indexPath.row);
    }
}

@end
